import { createRouter, createWebHistory } from 'vue-router'

import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import Search from '@/views/Search/index.vue'
import Play from '@/views/Play/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/layout'
    },
    {
      path: '/layout',
      component: Layout,
      redirect: '/layout/home',
      children: [
        {
          path: 'home',
          component: Home,
          meta: {
            // meta保存路由对象额外信息的
            title: '首页'
          }
        },
        {
          path: 'search',
          component: Search,
          meta: {
            title: '搜索'
          }
        }
      ]
    },
    {
      path: '/play',
      component: Play
    }
  ]
})

export default router
